from django.db import models
from control.models.User import User
import uuid

# 语言表，可配置
class Language(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="language_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="language_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="language_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "语言"           # 单数名称
        verbose_name_plural = "Languages"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 关键词类别，可配置
class KeywordType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="keyword_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="keyword_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="keyword_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "关键词类别"           # 单数名称
        verbose_name_plural = "KeywordTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 部门类别，可配置
class DepartmentType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="depar_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="depar_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="depar_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "部门类别"           # 单数名称
        verbose_name_plural = "DepartmentTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 机构类别，可配置
class InstitutionType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="inst_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="inst_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="inst_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "机构类别"           # 单数名称
        verbose_name_plural = "InstitutionsTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 文献状态类别，可配置
class LiteratureStatusType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="liter_status_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="liter_status_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="liter_status_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "文献状态类别"           # 单数名称
        verbose_name_plural = "LiteratureStatusTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 引文类型，可配置（值为专利、归档文件等等）
class LiteratureType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="liter_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="liter_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="liter_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "引文类型"           # 单数名称
        verbose_name_plural = "LiteratureTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name
    

# 期刊出版周期类型，可配置
class JournalPublicationCycleType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="jpct_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="jpct_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="jpct_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "期刊出版周期类型"           # 单数名称
        verbose_name_plural = "JournalPublicationCycleTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name 
    

# 会议开会周期类型，可配置
class ConferenceMeetingCycleType(models.Model): 
    uuid = models.UUIDField(primary_key = True,auto_created = True,default = uuid.uuid4,editable = False)
    name = models.CharField(verbose_name="名称", max_length=128)
    zh_name = models.CharField(verbose_name="中文名", max_length=128)
    
    creator = models.ForeignKey(User, verbose_name="创建者", related_name="cmct_type_creator", on_delete=models.CASCADE)				
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    last_editor = models.ForeignKey(User, verbose_name="最后编辑者", related_name="cmct_type_last_editor", on_delete=models.CASCADE)	
    last_edit_date = models.DateTimeField(verbose_name='最后编辑时间', auto_now=True)					
    reviewer = models.ForeignKey(User, verbose_name="审核者", related_name="cmct_type_reviewer", on_delete=models.CASCADE, null=True)
    review_date = models.DateTimeField(null=True, blank=True, verbose_name='审核时间')
    
    class Meta:
        ordering = ['-name', '-zh_name']
        verbose_name = "会议开会周期类型"           # 单数名称
        verbose_name_plural = "ConferenceMeetingCycleTypes"   # 复数名称

    def __str__(self):
        return self.name + ': ' + self.zh_name  